import 'package:flutter/material.dart';

import '../../../bean/waterinvasion_bean.dart';
import '../../../common/data_source.dart';
import '../../../common/system_config.dart';
import '../../../utils/tools/analysis_code.dart';
import '../../../utils/tools/screenutil_tool.dart';

class ListWidget extends StatelessWidget {
  List<Widget> lw  = [];

  ListWidget(BuildContext context,List<WaterinVasionBean> data) {
    TextStyle textStyle = TextStyle(fontSize: SystemConfig.fs_content3);

    for(int i = 0;i < data.length; i++){
      lw.add(
        Container(
          width: double.infinity,
          margin: EdgeInsets.only(top: ST.seth(20)),
          padding: EdgeInsets.symmetric(vertical: ST.seth(20),horizontal: ST.setw(20)),
          decoration: BoxDecoration(
            color: Theme.of(context).backgroundColor,
            borderRadius: BorderRadius.all(Radius.circular(8)),
            boxShadow: [
              BoxShadow(
                offset: Offset(0, 2), //x,y轴
                color: Color.fromRGBO(0, 0, 0, .1),
                blurRadius: 3 //投影距离
              )
            ]
          ),
          child: Column(
            children: [
              Padding(
                padding: EdgeInsets.only(bottom: ST.seth(20)),
                child: Row(
                  mainAxisAlignment: MainAxisAlignment.spaceBetween,
                  children: [
                    Text("${data[i].sensorName}",style: textStyle),
                    Text("${data[i].createTime}",style: textStyle)
                  ],
                ),
              ),
              SizedBox(
                width: double.infinity,
                height: 1,
                child: Container(
                  color: SystemConfig.borderColor,
                ),
              ),
              Padding(
                padding: EdgeInsets.only(top: ST.seth(20)),
                child: Row(
                  mainAxisAlignment: MainAxisAlignment.spaceBetween,
                  children: [
                    Text("是否水浸",style: textStyle),
                    Text("${analysisCode(data[i].status,waterEquipmentStateSourceData)["value"]}",
                      style: TextStyle(
                        color: data[i].status != 0 ? Colors.red : Colors.green,
                        fontSize: SystemConfig.fs_content3
                      )
                    )
                  ],
                ),
              )
            ],
          ),
        ),
      );
    }
  }

  @override
  Widget build(BuildContext context) {
    return Column(children: lw);
  }
}